# 变量赋值
num = 1
isRight = true
obj =
  a: 5
  b: 'str'
  fun:->
    @a
console.log(obj.fun())

# 函数定义
func = ->
 obj.a+num

# 函数默认值
func2 = (name,age=20) ->
  console.log(name+': '+age)

# 简单if
str='str'
str+='abc' if isRight

# 标准if。。。else
if str is 'str'
  str+='abc'
else if str is 'abc'
  str+='str'

age=12
# 范围判断
isStudent=10<age<25
console.log(isStudent)

# 数组定义
arr=[1,2,3,4,5]

# 数组遍历
for item in arr
  console.log(item)

# while循环
console.log(arr.pop()) while arr.length>0

# 推导
obj2={
  key:'abc'
  value:'def'
  class:'This is class'
}
console.log key,value for key,value of obj2 when key isnt 'key'

# 函数自调用
func2('小明')
do ->
  console.log('self call')

# 存在性
nullStr=null
if nullStr?
  console.log('nullStr is null')

# 如果null或者undefined，那么赋值
str?='AA'

# 嵌入js
func3= `function abc(){console.log('func3');}`
func3()

#try...catch
try
  a5=abc
catch err
  console.log(err)
finally
  console.log('finally')

###
  多行注释
###